class Transaction < ActiveRecord::Base

  belongs_to :room
  belongs_to :status
  belongs_to :customer

  before_save :set_checkout_time
  before_save :set_total_price


  private

   def set_checkout_time
     self.check_out = self.check_in.localtime + self.time.hours
   end

   def set_total_price
     room_price = Room.find(self.room_id).price
     self.total_price = room_price * self.time
   end
end